package dk.itu.KrakMap;

import java.awt.Color;

/**
 * enum class to give each of the different type of roads individual details and info.
 *
 * @author ITU-KF04-2011, Group 11
 */
public enum RoadType {

    MOTORVEJ(1, "Motorvej", 130),
    Motortrafikvej(2, "Motortrafikvej", 90),
    Primaerrute(3, "Primærrute", 80),
    Sekundaerrute(4, "Sekundærrute", 80),
    Vej(5, "Vej", 50),
    Andenvej(6, "Vej", 50),
    Sti(8, "Sti", 10),
    markvej(10, "Markvej", 40),
    gaagader(11, "Gågade", 10),
    projmotorvej(21, "Vej", 130),
    projmotortrafikvej(22, "Projekteret vej", 90),
    projprimaervej(23, "Projekteret vej", 80),
    projsekundaervej(24, "Projekteret vej", 80),
    Projvej(25, "Projekteret vej", 50),
    Projandenvej(26, "Projekteret vej", 50),
    Projsti(28, "Projekteret vej", 10),
    Motorvejsafkorsel(31, "Motorvejsafkørsel", 40),
    Motortrafikvejsafkorsel(32, "Motortrafikvejsafkørsel", 40),
    Primaervejsafkorsel(33, "Primærruteafkørsel", 40),
    Sekundaervejsafkorsel(34, "Sekundærruteafkørsel", 40),
    Andenvejafkorsel(35, "Afkørsel", 40),
    Motorvejstunnel(41, "Motorvejstunnel", 110),
    Motortrafikvejstunnel(42, "Motortrafikvejstunnel", 110),
    Primaervejstunnel(43, "Vej", 80),
    Sekundaervejstunnel(44, "Vej", 80),
    Andenvejtunnel(45, "Vej", 50),
    Mindrevejtunnel(46, "Vej", 50),
    Stitunnel(48, "Vej", 10),
    Faergeforbindelse(80, "Færge", 55),
    Stednavn(99, "Stednavn", 0);
    private int typenr;
    private String typename;
    private int speed;
    private float size;
    private float minSize;
    private Color color;
    private boolean stroke;
    private double strokeFactor;
    private Color strokeColor;
    private int priority;

    static {
        MOTORVEJ.setSize(30);
        MOTORVEJ.setColor(Color.RED);
        MOTORVEJ.setMinSize(5);
        MOTORVEJ.setStroke(true);
        MOTORVEJ.setPriority(1);

        Primaerrute.setColor(Color.DARK_GRAY);
        Primaerrute.setSize(16);
        Primaerrute.setMinSize(3);
        Primaerrute.setStrokeColor(Color.black);
        Primaerrute.setStrokeFactor(0.9);
        Primaerrute.setStroke(true);
        Primaerrute.setPriority(2);

        Sekundaerrute.setColor(Color.GRAY);
        Sekundaerrute.setMinSize(3);
        Sekundaerrute.setSize(12);
        Sekundaerrute.setStrokeColor(Color.BLACK);
        Sekundaerrute.setStrokeFactor(0.9);
        Sekundaerrute.setStroke(true);
        Sekundaerrute.setPriority(3);

        Motortrafikvej.setColor(Color.BLACK);
        Motortrafikvej.setMinSize(3);
        Motortrafikvej.setSize(12);
        Motortrafikvej.setStrokeColor(Color.BLACK);
        Motortrafikvej.setStrokeFactor(0.9);
        Motortrafikvej.setStroke(true);
        Motortrafikvej.setPriority(4);

        Vej.setSize(14);
        Vej.setMinSize(3);
        Vej.setColor(Color.LIGHT_GRAY);
        Vej.setStrokeColor(Color.BLACK);
        Vej.setStrokeFactor(0.7);
        Vej.setStroke(true);
        Vej.setPriority(5);

        Andenvej.setColor(Color.BLACK);
        Andenvej.setSize(6);
        Andenvej.setMinSize(1);
        Andenvej.setStrokeColor(Color.BLACK);
        Andenvej.setStrokeFactor(0.7);
        Andenvej.setStroke(true);
        Andenvej.setPriority(6);

        Faergeforbindelse.setSize(2);
        Faergeforbindelse.setMinSize(1);
        Faergeforbindelse.setColor(Color.BLUE);
        Faergeforbindelse.setPriority(8);

        Sti.setSize(2);
        Sti.setMinSize(1);
        Sti.setColor(Color.GREEN);
        Sti.setPriority(9);

        Motorvejsafkorsel.setColor(Color.RED);
        Motorvejsafkorsel.setSize(10);
        Motorvejsafkorsel.setMinSize(3);
        Motorvejsafkorsel.setPriority(7);
        Motorvejsafkorsel.setStrokeColor(Color.BLACK);
        Motorvejsafkorsel.setStrokeFactor(0.95);
        Motorvejsafkorsel.setStroke(true);
    }

    /**
     * Create a new RoadType from a typenumber, a name and speed.
     * @param typenr int
     * @param typename String
     * @param speed int
     */
    RoadType(int typenr, String typenavn, int speed) {
        this.typenr = typenr;
        this.typename = typenavn;
        this.speed = speed;
        this.size = 5;
        this.minSize = 2;
        this.color = Color.BLACK;
        this.stroke = false;
        this.strokeFactor = 0.8;
        this.strokeColor = Color.BLACK;
        this.priority = 1000;

    }

    /**
     * get the RoadType from a typenr parameter
     * @param typenr int the typenr to find the matching RoadType
     * @return RoadType
     */
    public static RoadType getRoadType(int typenr) {
        for (RoadType r : RoadType.values()) {
            if (r.getTypenr() == typenr) {
                return r;
            }
        }
        return Vej;
    }

    /**
     * @return the typenr
     */
    public int getTypenr() {
        return typenr;
    }

    /**
     * @return the typename
     */
    public String getTypename() {
        return typename;
    }

    /**
     * @return the speed
     */
    public int getSpeed() {
        return speed;
    }

    /**
     * @return the size
     */
    public float getSize() {
        return size;
    }

    /**
     * @return the minSize
     */
    public float getMinSize() {
        return minSize;
    }

    /**
     * @return the color
     */
    public Color getColor() {
        return color;
    }

    /**
     * @return the stroke
     */
    public boolean isStroke() {
        return stroke;
    }

    /**
     * @return the strokeFactor
     */
    public double getStrokeFactor() {
        return strokeFactor;
    }

    /**
     * @return the strokeColor
     */
    public Color getStrokeColor() {
        return strokeColor;
    }

    /**
     * @return the priority
     */
    public int getPriority() {
        return priority;
    }

    /**
     * @param typenr the typenr to set
     */
    private void setTypenr(int typenr) {
        this.typenr = typenr;
    }

    /**
     * @param typenavn the typenavn to set
     */
    private void setTypenavn(String typenavn) {
        this.typename = typenavn;
    }

    /**
     * @param speed the speed to set
     */
    private void setSpeed(int speed) {
        this.speed = speed;
    }

    /**
     * @param size the size to set
     */
    private void setSize(float size) {
        this.size = size;
    }

    /**
     * @param minSize the minSize to set
     */
    private void setMinSize(float minSize) {
        this.minSize = minSize;
    }

    /**
     * @param color the color to set
     */
    private void setColor(Color color) {
        this.color = color;
    }

    /**
     * @param stroke the stroke to set
     */
    private void setStroke(boolean stroke) {
        this.stroke = stroke;
    }

    /**
     * @param strokeFactor the strokeFactor to set
     */
    private void setStrokeFactor(double strokeFactor) {
        this.strokeFactor = strokeFactor;
    }

    /**
     * @param strokeColor the strokeColor to set
     */
    private void setStrokeColor(Color strokeColor) {
        this.strokeColor = strokeColor;
    }

    /**
     * @param priority the priority to set
     */
    private void setPriority(int priority) {
        this.priority = priority;
    }
}
